<template>
	<view>
		<view class="icebody">
			<view class="mask"></view>
			<view class="login">
				<iceLoginPrePaper v-if="prePaper" />
				<iceLogin v-else />
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		onLoad,
		onShow,
		onHide,
		onReady
	} from '@dcloudio/uni-app'
	import iceLogin from '@/components/cpn/iceLogin.vue'
	import iceLoginPrePaper from '@/components/cpn/iceLoginPrePaper.vue'
	import {
		iceGetStorage, iceRemoveStorage, iceSetStorage
	} from '../../utils/common';
	const second = ref(6)
	const setIntervalID = ref(null)
	const prePaper = ref(false)
	onLoad(() => {
		// console.log(e);
		// if (process.env.NODE_ENV === 'development') {
		// 	// iceSetStorage('id', 2)
		// 	const href = window.location; // 获取查询字符串部分
		// 	console.log(href);
		// } else {
		// 	const search = window.location.search; // 获取查询字符串部分
		// 	iceSetStorage('id', search.replace('?id=', ''))
		// }
		const iceRemoveStorages = ()=>{
			iceRemoveStorage('id')
			iceRemoveStorage('userId')
		}
		const search = window.location.search; // 获取查询字符串部分
		if(search.indexOf('?adc=') != -1){
			// 如果是手机阅卷，清除所有答题的登录状态
			iceRemoveStorages()
			prePaper.value = true
			return
		}
		iceSetStorage('id', parseInt(search.replace('?id=', '')))
	})
	
	const toPage = () => {
		second.value = 6
		setIntervalID.value = setInterval(() => {
			second.value--
			if (second.value < 1) {
				clearInterval(setIntervalID.value)
				uni.navigateTo({
					url: '/pages/home/index',
				})
			}
		}, 1000)
	}
	const toHome = () => {
		uni.navigateTo({
			url: '/pages/home/index',
		})
	}
</script>

<style scoped lang="scss">
	.icebody {
		position: relative;

		.mask {
			width: 100%;
			height: 100vh;
			background-color: rgba(0, 0, 0, 0.7);
		}

		.login {
			position: absolute;
			top: 38.2%;
			left: 50%;
			width: 600rpx;
			margin-left: -300rpx;
			margin-top: -400rpx;
			padding: 20px 0;
			border-radius: 12rpx;
			background-color: rgba(255, 255, 255, 0.4);
			z-index: 9999;
		}
	}
</style>